package demo;
import com.tedu.InputUtil;

import java.util.Scanner;
public class Demo {
    public static void main(String[] args) {
//        Scanner sc = new Scanner(System.in);
//        System.out.println("欢迎光临 ");
//        System.out.println("请输入你的名字");
//        String name = sc.nextLine();
//        System.out.println("欢迎 " + name + " 来到本店");
//        System.out.println("请输入你的年龄");
//        int age = sc.nextInt();
        regUser();
    }
//        User user = InputUtil.getInputObject(new User(), "欢迎注册");
//        System.out.println(user);
//
//        UserMapper userMapper = new UserMapper();
//        int num = userMapper.insert(user);
//        System.out.println(num>0?"恭喜您注册成功":"注册失败了");
    // 用户登录操作
    public static void loginUser(String[] args){
        loginUser();
    }

        /*
        *用户注册操作
         */
    public static void regUser() {

        User user = InputUtil.getInputObject(new User(), "欢迎注册");
        System.out.println(user);

        UserMapper userMapper = new UserMapper();
        int num = userMapper.insert(user);
        System.out.println(num > 0 ? "恭喜您注册成功" : "注册失败了");
        /*
         * 用户登录操作
         */
    }

    public static void loginUser(){
        UserDTO dto = InputUtil.getInputObject(new UserDTO(), "欢迎登录");
        System.out.println(dto);


        UserMapper userMapper = new UserMapper();
        User user = userMapper.selectByUsername(dto.getUsername());
        System.out.println(user);




    }


}
